package com.moonlight.mina;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

public class MinaEncodingFactory implements ProtocolCodecFactory {
	private Charset charset;
	
	private MinaEncoder minaEncoder;
	
	private MinaDecoder minaDecoder;
	
	public MinaEncodingFactory(Charset charset) {
		// TODO Auto-generated constructor stub
		this.minaEncoder = new MinaEncoder(charset);
		this.minaDecoder = new MinaDecoder(charset);
	}

	@Override
	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		// TODO Auto-generated method stub
		return this.minaEncoder;
	}

	@Override
	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		// TODO Auto-generated method stub
		return this.minaDecoder;
	}

}
